package observe;

import subject.Subject;

/**
 * 具体的观察者 实现父接口
 *
 * @author tengqingya
 * @create 2017-01-17 10:41
 */
public class ConcreteObserver implements Observer {
    /**
     * 观察者状态 用于和观察对象保持一致
     */
    private String status;

    /**
     * 根据choice确定是否改变状态
     * 即有选择的被通知
     */
    private int choice;

    public int getChoice() {
        return choice;
    }

    public void setChoice( int choice ) {
        this.choice = choice;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus( String status ) {
        this.status = status;
    }

    public void setObserverStatus( String status ) {
        this.status = status;
    }

    public int getChoiceStatus() {
        return this.choice;
    }

    public void update( Subject subject ) {
        setObserverStatus(subject.getSubjectStatus());
    }

    @Override
    public String toString() {
        return "ConcreteObserver{" +
                "status='" + status + '\'' +
                '}';
    }
}
